package com.xbongbong.paas.connection.service;

import com.xbongbong.paas.connection.enums.OpenAppEnum;
import com.xbongbong.paas.connection.service.imp.CloudCodeService;
import com.xbongbong.paas.connection.service.imp.DdConnectorService;
import com.xbongbong.paas.connection.service.imp.EsignForConnectionService;
import com.xbongbong.paas.connection.service.imp.MeikeService;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class OpenAppFactory {

    @Resource
    private MeikeService meikeService;
    @Resource
    private EsignForConnectionService esignForConnectionService;
    @Resource
    private CloudCodeService cloudCodeService;
    @Resource
    private DdConnectorService ddConnectorService;


    public IOpenAppService openAppFactory(OpenAppEnum openAppEnum) throws XbbException {


        switch (openAppEnum) {
            case MEI_KE_BAO_XIAO:
                return meikeService;
            case ESIGN:
                return esignForConnectionService;
            case CLOUD_CODE:
                return cloudCodeService;
            case DD_CONNECTOR:
                return ddConnectorService;
            default:
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100028, "枚举类型错误！");
        }
    }
}
